#include <iostream>
#include <assert.h>

using namespace std;

/*
class Time{
public:
    Time(){
        cout << "Time()" << endl;
    }
    ~Time(){
        cout << "~Time()" << endl;
    }
private:
    int _hour;
    int _minute;
    int _second;
};

class Data{
public:
*/
/*    Data(int year = 1, int month = 1, int day = 1){
        cout << "Data()" << endl;
        _year = year;
        _month = month;
        _day = day;
    }
    Data(const Data& d){
        cout << "Data(Data& d)" << endl;
        _year = d._year;
        _month = d._month;
        _day = d._day;
    }*//*

private:
    int _year = 2017;
    int _month = 10;
    int _day = 10;
    Time _t;
};

void Func1(Data d){
    cout << "Func1()" << endl;
}

void Func2(Data& d){
    cout << "Func2()" << endl;
}

void test1() {
    Data d1;
    Data d2(d1);//拷贝构造
    Data d3 = d1;//拷贝构造
    Func2(d1);
    Func1(d1);
}

void test2(){
    Data d1;
}

int main(){
    test2();
    return 0;
}
*/

/*
class Data{
public:
    Data(int year = 2017, int month = 10, int day = 10){
        cout << "Data()" << endl;
    }
    Data(const Data& d){
        cout << "Data(const Data& d)" << endl;
    }
    ~Data(){
        cout << "~Data()" << endl;
    }
private:
    int _year;
    int _month;
    int _day;
};

Data Test(Data d){
    Data tmp(d);
    return tmp;
}

int main(){
    Data d1;
    Test(d1);
    Data d2 = d1;
    return 0;
}
*/


/*
class Data{
public:
    Data(int year = 2017, int month = 9, int day = 25){
        _year = year;
        _month = month;
        _day = day;
    }

    Data(const Data& d){
        cout << "copy" << endl;
        _year = d._year;
        _month = d._month;
        _day = d._day;
    }

    int GetMonthDay(int year, int month){
        assert(month > 0 && month < 13);
        int monthArray[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        if(month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
            return 29;
        else
            return monthArray[month];
    }

    Data GetAfterXDay(int x){
        Data tmp(*this);
        tmp._day += x;
        while (tmp._day > GetMonthDay(tmp._year,tmp._month)){
            tmp._day -= GetMonthDay(tmp._year,tmp._month);
            ++tmp._month;
            if(tmp._month == 13){
                tmp._year++;
                tmp._month = 1;
            }
        }
        return tmp;
    }

    Data& GetAfterXDayChange(int x){
        _day += x;
        while (_day > GetMonthDay(_year,_month)){
            _day -= GetMonthDay(_year,_month);
            ++_month;
            if(_month == 13){
                ++_year;
                _month = 1;
            }
        }
        return *this;
    }

    void Print(){
        cout << _year << "/" << _month << "/" << _day << endl;
    }

private:
    int _year;
    int _month;
    int _day;
};

int main(){
    Data d1(2023,3,17);
    Data d2 = d1.GetAfterXDay(100);
    Data d3 = d1.GetAfterXDay(200);
    d1.Print();
    d2.Print();
    d3.Print();

    d1.GetAfterXDayChange(150);
    d1.Print();
}
*/

class Data{
public:
    explicit Data(int year = 2017, int month = 10, int day = 10){
        _year = year;
        _month = month;
        _day = day;
    }

    Data(const Data& d){
        _year = d._year;
        _month = d._month;
        _day = d._day;
    }

    void Print() const{
        cout << _year << '/' << _month << '/' << _day << endl;
    }

    static int GetMonthDay(int year, int month){
        assert(month > 0 && month < 13);
        int monthArray[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
        if(month == 2 && ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)))
            return 29;
        else
            return monthArray[month];
    }

    Data& GetAfterXDayChange(int x){
        _day += x;
        while (_day > GetMonthDay(_year, _month)){
            _day -= GetMonthDay(_year, _month);
            ++_month;
            if (_month == 13){
                ++_year;
                _month = 1;
            }
        }
        return *this;
    }

    Data GetAfterXDay(int x){
        Data tmp = *this;
        tmp._day += x;
        while (tmp._day > GetMonthDay(tmp._year, tmp._month)){
            tmp._day -= GetMonthDay(tmp._year, tmp._month);
            ++tmp._month;
            if (tmp._month == 13){
                ++tmp._year;
                tmp._month = 1;
            }
        }
        return tmp;
    }

private:
    int _year;
    int _month;
    int _day;
};

int main(){
    Data d1;
    d1.Print();
    Data d2 = d1.GetAfterXDay(2000);
    d1.Print();
    d2.Print();
    return 0;
}